
//
//  MBSearchField.m
//  房源详情-小区详情
//
//  Created by MB__Lee on 2018/5/28.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "MBSearchField.h"

#define  HalfHight self.bounds.size.height * 0.5

@interface MBSearchField()



@end

@implementation MBSearchField

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)awakeFromNib{
    [super awakeFromNib];
    
    
    
    
    //设置圆角
    self.layer.cornerRadius = HalfHight;
    self.clipsToBounds = YES;
    
    // 设置左右占位图
    UIImageView *rightView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fangdajing_icon"]];
    self.rightView = rightView;
    self.rightViewMode = UITextFieldViewModeAlways;
    
  
    UIView *leftview = [[UIView alloc] initWithFrame:CGRectMake(0, 0,HalfHight- 3 , 30)];
    self.leftView = leftview;
    self.leftViewMode = UITextFieldViewModeAlways;
    
    // 设置占位文字
//    self.placeholder = @"请输入小区名称或者地址";
    self.placeholder = @"请输入搜索关键字";
    
    //设置光标颜色
    self.tintColor = [UIColor grayColor];
    
}

-(CGRect)rightViewRectForBounds:(CGRect)bounds{
    CGRect rightFrame = [super rightViewRectForBounds:bounds];
    rightFrame.origin.x -= HalfHight;
    return  rightFrame;
}
-(CGRect)textRectForBounds:(CGRect)bounds{
    CGRect textFrame = [super textRectForBounds:bounds];
    textFrame.origin.x += HalfHight;
    textFrame.size.width -= HalfHight;
    return  textFrame;
}
//-(CGRect)placeholderRectForBounds:(CGRect)bounds{
//    CGRect placeHoldFrame = [super placeholderRectForBounds:bounds];
//    placeHoldFrame.origin.x += 16;
//    return  placeHoldFrame;
//}

@end
